package com.wangshuo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangshuo.config.Result;
import com.wangshuo.entity.User;
import com.wangshuo.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;
    @GetMapping("/list")
    public Result list(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@RequestParam String keyword){
        IPage<User> page=new Page<>(pageNum,pageSize);
        IPage<User> page1=userService.getpage(page,keyword);
        return Result.ok(page1);

    }
    @GetMapping("/delete")
    public Result delete(@RequestParam Integer id){
        userService.removeById(id);
        return Result.ok("成功");
    }
}
